$(document).ready(function(){
	$( "#createDate" ).datepicker();
	$( "#createDate" ).datepicker( "option",$.datepicker.regional[ 'zh-CN'] );
	
	$("#submitButton").click(function(){
		var existEmpty=false;
		$.each($("#memberForm input[type='text']"),function(i,data){
			if($(data).val()=="") 
			{
				if($(data).attr("name")!="address"){
					existEmpty=true;
				}
				if(existEmpty){
					return;
				}
			}
		});
		if(!existEmpty){
			$("#submitButton").attr("disabled","disabled");
			$.post(getRootPath()+ "/MainMenu/members/insertMember.htm", $("#memberForm").serializeArray(), function(data){
				$("#submitButton").removeAttr("disabled");
				$("#memberForm input[type='text']").val("");
				$("#memberForm textarea").val("");
				if(data.isSuccessfull==true){
					alert("保存成功");
				}else{
					alert("保存失败");
				}
			});
		}else{
			alert("*项都是必须填的");
		}
	});
	
	$("#calculateProfitAmount").click(function(){
		var cost = $("#costAmount").val();
		var percent = $("#profitPercent").val();
		$("#profitAmount").val(accMul(cost,accDiv(percent,100)));
	});
});

